package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.DeptDailyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.DeptDailyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.DeptDailyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.DeptDailyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.DeptDailyGasConsumeQueryModel;
import com.hzhr.iot.statis.queryModel.custom.DeptDailyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class DeptDailyGasConsumeDao {
    @Autowired
    DeptDailyGasConsumeEntityMapper deptDailyGasConsumeEntityMapper;
    @Autowired
    DeptDailyGasConsumeEntityCustomMapper deptDailyGasConsumeEntityCustomMapper;

    public int insert(DeptDailyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptDailyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(DeptDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptDailyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(DeptDailyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = deptDailyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(DeptDailyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = deptDailyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public DeptDailyGasConsumeEntity selectEntity(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeptDailyGasConsumeEntity> selectEntityList(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<DeptDailyGasConsumeEntity> entityList = new ArrayList<>();
        for (DeptDailyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public DeptDailyGasConsumeEntityExt selectExt(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<DeptDailyGasConsumeEntityExt> selectExtList(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return null;
        List<DeptDailyGasConsumeEntityExt> extList = deptDailyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = deptDailyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }

    public Double selectDataSum(DeptDailyGasConsumeQueryModel queryModel) {
        if (queryModel == null) return 0.0;
        Double dataSum = deptDailyGasConsumeEntityCustomMapper.selectDataSum(queryModel);
        dataSum = dataSum == null ? 0.0 : dataSum;
        return dataSum;
    }
}
